const draughtSource = require('./../module/draught_source');
const mysqlClass = require('./../utils/mysql');
const mysqlConf = require('./../utils/mysqlConf.json');

let mysql = new mysqlClass(mysqlConf);
let ds1 = new draughtSource();
let tableName = 'draught_source';
let cb = (text,err,ret) => {
    console.log(`======================== ${text} ========================`);
    console.log(err);
    console.log(ret);
    console.log(`======================== ${text} ========================`);
};

ds1.id = 'test1';
ds1.dtype = 'ibas';
ds1.year = "2000";
ds1.eday = "12";
ds1.path = "test1path";

mysql.setDatabase("zyzx");

mysql.save({
    table: tableName,
    data: ds1
},cb.bind(null,'save'));

mysql.select({
    table: tableName,
    data: {
        conditionStr: "id='test1'"
    }
},cb.bind(null,'select'));

mysql.update({
    table: tableName,
    data: {
        conditionStr: "id='test1'",
        setStr: "dtype='bing'"
    }
},cb.bind(null,'update'));

mysql.query({
    table: tableName,
    sql: `select * from ${tableName} where dtype='lst' and year='2000'`
},cb.bind(null,'query'));

mysql.delete({
    table: tableName,
    data: {
        conditionStr: "id='test1'",
    }
},cb.bind(null,'delete'));




